package com.ces.hk.mybatis.dao.service.impl;

import java.io.IOException;

import com.ces.hk.mybatis.dao.UserDao;
import com.ces.hk.mybatis.dao.service.MapperService;
import com.ces.hk.mybatis.factory.SessionFactory;
import com.ces.hk.mybatis.model.User;

public class UserDaoServiceImpl implements UserDao, MapperService {

	final UserDao userDao = (UserDao) getMapper();

	@Override
	public Object getMapper() {
		UserDao userDao = null;
		try {
			userDao = SessionFactory.getSqlSession().getMapper(UserDao.class);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return userDao;
	}

	@Override
	public int insert(User user) {

		return userDao.insert(user);
	}

	@Override
	public int countAll() {

		return userDao.countAll();
	}

	@Override
	public int findId(String name) {
		// TODO Auto-generated method stub
		return 0;
	}

	public static void main(String[] args) {
		UserDaoServiceImpl userDaoServiceImpl = new UserDaoServiceImpl();
		System.out.println(userDaoServiceImpl.countAll());

	}

}
